package com.li.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.li.mapper.NoticesMapper;

import com.li.pojo.po.Notice;
import com.li.pojo.po.PageResult;
import com.li.service.NoticeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl extends ServiceImpl<NoticesMapper, Notice> implements NoticeService {
    @Autowired
    private NoticesMapper noticesMapper;

    @Override
    public PageResult getPage(Integer pageNum, Integer pageSize, String status) {
        Page<Notice> pageBean = PageHelper.startPage(pageNum,pageSize);
        List<Notice> page = noticesMapper.getPage(status);
        PageResult pageResult = new PageResult(200, "查询成功", null, pageBean.getResult(), pageBean.getTotal());
//        PageResult pageResult = new PageResult(200, "查询成功", null, page,(long) page.size());
        return pageResult;
    }

    @Override
    public void updateByNoticeId(Integer noticeId) {
        noticesMapper.updateByNoticeId(noticeId);
    }
}
